<template>
  <div>
    <h2>商品列表</h2>
    <ul>
      <li v-for="item in sparr" :key="item.id" @click="dianjixinxi(item)">
        {{ item.title }}
      </li>
    </ul>
    <div>
      <h2>商品详情</h2>
      <p v-if="xiangq">
        商品序号：{{ xiangq.id }}-名称：{{ xiangq.title }}-单价：{{ xiangq.price }}
      </p>
      <!-- <p>{{ xiangq }}</p> -->
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

interface infof {
  id: number
  title: string
  price: number
}

const porps = defineProps<{
  sparr: Array<infof>
}>()

const xiangq = ref<infof>()

const dianjixinxi = (item: infof) => {
  xiangq.value = { ...item }
}
</script>

<style lang="scss" scoped>
li {
  cursor: pointer;
}
</style>
